package edu.cs.usask.ca.silver.plugin.rcp.sourceprovider;

import java.util.Map;

import edu.cs.usask.ca.silver.businesslogic.ids.GroupID;
import edu.cs.usask.ca.silver.businesslogic.ids.ModelProjectID;
import edu.cs.usask.ca.silver.businesslogic.ids.ModelVersionID;
import edu.cs.usask.ca.silver.businesslogic.ids.ScenarioCollectionID;
import edu.cs.usask.ca.silver.businesslogic.ids.ScenarioID;
import edu.cs.usask.ca.silver.businesslogic.ids.SilverIDVisitor;
import edu.cs.usask.ca.silver.businesslogic.ids.UserID;

public final class SilverUISourceProviderSilverIDVisitorImpl implements
		SilverIDVisitor {

	private final SilverUISourceProvider sc;
	private final Map<String, String> map;

	public SilverUISourceProviderSilverIDVisitorImpl(SilverUISourceProvider sc,
			Map<String, String> propertyMap) {
		this.sc = sc;
		this.map = propertyMap;
	}

	@Override
	public void visit(UserID uId) throws Exception {
		map.put(SilverUISourceProvider.PROJECTVIEW_SELECTED_STATE,
				SilverUISourceProvider.SELECTED_USER);
		sc.fireSourceChangedForProjectViewSelectedState(SilverUISourceProvider.SELECTED_USER);
	}

	@Override
	public void visit(GroupID gId) throws Exception {
		map.put(SilverUISourceProvider.PROJECTVIEW_SELECTED_STATE,
				SilverUISourceProvider.SELECTED_GROUP);
		sc.fireSourceChangedForProjectViewSelectedState(SilverUISourceProvider.SELECTED_GROUP);
	}

	@Override
	public void visit(ModelProjectID mpId) throws Exception {
		map.put(SilverUISourceProvider.PROJECTVIEW_SELECTED_STATE,
				SilverUISourceProvider.SELECTED_MP);
		sc.fireSourceChangedForProjectViewSelectedState(SilverUISourceProvider.SELECTED_MP);
	}

	@Override
	public void visit(ModelVersionID mvId) throws Exception {
		map.put(SilverUISourceProvider.PROJECTVIEW_SELECTED_STATE,
				SilverUISourceProvider.SELECTED_MV);
		sc.fireSourceChangedForProjectViewSelectedState(SilverUISourceProvider.SELECTED_MV);
	}

	@Override
	public void visit(ScenarioCollectionID scId) throws Exception {
		map.put(SilverUISourceProvider.PROJECTVIEW_SELECTED_STATE,
				SilverUISourceProvider.SELECTED_SC);
		sc.fireSourceChangedForProjectViewSelectedState(SilverUISourceProvider.SELECTED_SC);
	}

	@Override
	public void visit(ScenarioID sId) throws Exception {
		map.put(SilverUISourceProvider.PROJECTVIEW_SELECTED_STATE,
				SilverUISourceProvider.SELECTED_S);
		sc.fireSourceChangedForProjectViewSelectedState(SilverUISourceProvider.SELECTED_S);
	}

}
